#!/usr/bin/python
# -*- coding:utf-8 -*-
# __author__ = 'zhuyan'
import logging, time
'''
自定义日志类。将日志写到D:/log/${app}/${app}_detail.log目录。
'''
log_name = 'file_log'
LEN = 30
FILL = "*"


class Log:

    def __init__(self):
        # #########################################日志基础配置###########################################
        # now_time = time.strftime("%Y-%m-%d %H:%M:%s", time.localtime(time.time()))
        # logging.info(now_time)
        fmt = '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'
        logging.basicConfig(level=logging.DEBUG,
                            format=fmt,
                            datefmt='%a, %d %b %Y %H:%M:%S')

        formatter = logging.Formatter(fmt=fmt, datefmt="%a, %d %b %Y %H:%M:%S")

        file_handler = logging.FileHandler(filename="/b.log", mode="a", encoding="utf-8", delay=True)
        file_handler.setLevel(logging.INFO)
        file_handler.setFormatter(formatter)

        logging.getLogger(log_name).addHandler(file_handler)
        # ##############################################################################################

    def getLog(self):
        return logging.getLogger(log_name)

if __name__ == '__main__':
    a = Log()
    Log.info(u"测试一下")
    Log.debug("怎么")
